package com.example.sqlite_address_list;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

public class AddressSqlite extends SQLiteOpenHelper {
    private final static String dbName = "address_sql.db";
    private static String tableName = "addressInformation";
    private static String colName = "name";
    private static String colPhone = "phone";

    public static String getDbName() {
        return dbName;
    }

    public static String getTableName() {
        return tableName;
    }

    public static String getColName() {
        return colName;
    }

    public static String getColPhone() {
        return colPhone;
    }

    public AddressSqlite( Context context) {
        super(context, getDbName(), null, 4);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.v("life","onCreate()");
        String sql = "create table "+tableName+" (id integer primary key autoincrement,"+colName+"  varchar(20) ,"+colPhone+" varchar(20))";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
